//
//  ZHCollectionReusableView.m
//  XMLYFM
//
//  Created by dllo on 16/1/5.
//  Copyright © 2016年 zzl. All rights reserved.
//

#import "ZHCollectionReusableView.h"
#import "BaseLabel.h"
#import "Masonry.h"


@interface ZHCollectionReusableView ()

@property (nonatomic,strong)BaseLabel *topLabel;
@property (nonatomic,strong)BaseButton *moreButton;


@end


@implementation ZHCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self creatSubviews];
        
    }
    return self;
}

- (void)creatSubviews{
    
    UIImageView *topImageView = [[UIImageView alloc]init];
    [self addSubview:topImageView];
    topImageView.image = [UIImage imageNamed:@"findsection_logo@2x.png"];
    
    _topLabel = [[BaseLabel alloc]init];
    [self addSubview:_topLabel];
    
    _moreButton = [BaseButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:_moreButton];
    [_moreButton setBackgroundImage:[UIImage imageNamed:@"liveRadioSectionMore_Normal@2x.png"] forState:UIControlStateNormal];
    [_moreButton setBackgroundImage:[UIImage imageNamed:@"liveRadioSectionMore_High@2x.png"] forState:UIControlStateHighlighted];
    [_moreButton addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];

    [topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(@10);
        make.size.mas_equalTo(CGSizeMake(20, 20));
        
    }];
    [_topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(topImageView);
        make.left.equalTo(topImageView).offset(30);
        make.size.mas_equalTo(CGSizeMake(130, 20));
    }];
    [_moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(@(-30));
        make.top.equalTo(topImageView);
        make.size.mas_equalTo(CGSizeMake(40, 18));
        
    }];
}

- (void)setBigModel:(ZHListBigModel *)bigModel{
    _bigModel = bigModel;
    _topLabel.text = bigModel.title;
//    NSLog(@"bigtitle = %@",bigModel.title);
    _moreButton.tag = [bigModel.myId integerValue] + 2050;
    
}

- (void)moreAction:(BaseButton *)btn{
//    NSLog(@"zh===%@",_name);
    [self.anchorCollectionDelegate presentToMoreViewController:btn.tag name:_bigModel.name];
}




@end
